Skip to content

[codex] Structure preview asset URL failures#3399

Merged
juliusmarminge merged 1 commit into
codex/stack-pr-3259from
codex/web-preview-error-context
Jun 21, 2026
Merged

[codex] Structure preview asset URL failures#3399
juliusmarminge merged 1 commit into
codex/stack-pr-3259from
codex/web-preview-error-context

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

  • replace malformed preview asset URL defects with BrowserPreviewAssetUrlInvalidError
  • preserve the exact URL parser cause for the full failure chain
  • attach safe environment, thread, file, URL-length, and expiry diagnostics; do not store the signed relative URL or raw base URL as direct structured attributes
  • cover cause identity and absence of direct raw URL attributes with a focused regression test

Scope

Stack dependency

Validation

  • pnpm vp test apps/web/src/browser/openFileInPreview.test.ts
  • pnpm vp check
  • pnpm vp run typecheck

Note

Medium Risk
Changes integrated-browser open paths and error typing in chat markdown; invalid asset URLs now fail recoverably instead of dying, with safer diagnostics around signed URLs.

Overview
Preview asset URL construction in openFileInPreview no longer uses resolveAssetUrl or Cause.die when the base/relative URL pair is invalid. It builds the URL with new URL(relative, base) and returns BrowserPreviewAssetUrlInvalidError via Cause.fail, carrying environment/thread/file context, URL lengths and expiry, and the original parser cause—without storing raw base or signed relative URLs.

Browser preview errors are refactored to Effect Schema.TaggedErrorClass types with fixed user-facing messages: BrowserPreviewUnavailableError (runtime unsupported), plus new BrowserPreviewThreadContextUnavailableError and BrowserPreviewEnvironmentDisconnectedError. ChatMarkdown returns these specific failures when opening links or workspace files in the integrated browser instead of overloading BrowserPreviewUnavailableError with ad hoc messages.

Tests in openFileInPreview.test.ts cover the fixed unavailable message, invalid-asset-URL diagnostics, cause identity, and that serialized errors do not leak signed tokens.

Reviewed by Cursor Bugbot for commit 56e0750. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Structure browser preview asset URL failures as typed errors in openFileInPreview

  • Replaces generic defect failures with typed Schema.TaggedErrorClass errors for three new failure cases: missing thread context (BrowserPreviewThreadContextUnavailableError), disconnected environment (BrowserPreviewEnvironmentDisconnectedError), and invalid asset URL (BrowserPreviewAssetUrlInvalidError).
  • BrowserPreviewAssetUrlInvalidError captures safe diagnostic fields (environmentId, threadId, filePath, httpBaseUrlLength, relativeUrlLength, expiresAt) and preserves the original cause, avoiding exposure of sensitive URL contents.
  • Replaces resolveAssetUrl with a new URL(relativeUrl, httpBaseUrl) call wrapped in try/catch; failures are surfaced as BrowserPreviewAssetUrlInvalidError instead of a defect die.
  • Exports isBrowserPreviewAssetUrlInvalidError as a type guard via Schema.is.
  • Behavioral Change: callers of openFileInPreview now receive typed failures for URL construction errors instead of unhandled defects.

Macroscope summarized 56e0750.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c935d6bb-72b9-4e0a-bb44-2ac2ce02b98a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/web-preview-error-context

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jun 20, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 20, 2026
@macroscopeapp

macroscopeapp Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

This PR refactors error handling for browser preview asset URLs, converting to Schema-based error classes with structured context fields while ensuring sensitive data isn't leaked. The changes are limited to error infrastructure with comprehensive test coverage.

You can customize Macroscope's approvability policy. Learn more.

@juliusmarminge juliusmarminge force-pushed the codex/web-preview-error-context branch from 6989347 to 199dc14 Compare June 20, 2026 15:36
@juliusmarminge juliusmarminge changed the title refactor(web): add structured preview errors [codex] Structure browser preview open failures Jun 20, 2026
@juliusmarminge juliusmarminge changed the base branch from main to codex/web-markdown-action-errors June 20, 2026 15:36
@macroscopeapp macroscopeapp Bot dismissed their stale review June 20, 2026 15:36

Dismissing prior approval to re-evaluate 199dc14

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 20, 2026
@juliusmarminge juliusmarminge force-pushed the codex/web-preview-error-context branch from 199dc14 to c048ffe Compare June 20, 2026 15:43
@juliusmarminge juliusmarminge changed the base branch from codex/web-markdown-action-errors to codex/stack-pr-3259 June 20, 2026 15:43
@macroscopeapp macroscopeapp Bot dismissed their stale review June 20, 2026 15:43

Dismissing prior approval to re-evaluate c048ffe

@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). labels Jun 20, 2026
@juliusmarminge juliusmarminge changed the title [codex] Structure browser preview open failures [codex] Structure preview asset URL failures Jun 20, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 20, 2026
@juliusmarminge juliusmarminge force-pushed the codex/web-preview-error-context branch from c048ffe to 215b085 Compare June 20, 2026 22:48
@juliusmarminge juliusmarminge force-pushed the codex/web-preview-error-context branch from 215b085 to 8751fdb Compare June 20, 2026 22:50
@juliusmarminge juliusmarminge force-pushed the codex/web-preview-error-context branch from 8751fdb to 087f4d1 Compare June 20, 2026 23:20
@juliusmarminge juliusmarminge force-pushed the codex/web-preview-error-context branch from 087f4d1 to 8c4c9b9 Compare June 20, 2026 23:43
@juliusmarminge juliusmarminge force-pushed the codex/web-preview-error-context branch from 8c4c9b9 to e2f90b8 Compare June 20, 2026 23:47
@juliusmarminge juliusmarminge force-pushed the codex/web-preview-error-context branch from e2f90b8 to 0de1a6f Compare June 21, 2026 00:00
@juliusmarminge juliusmarminge force-pushed the codex/web-preview-error-context branch 2 times, most recently from 8184293 to 6604762 Compare June 21, 2026 00:22
@macroscopeapp macroscopeapp Bot dismissed their stale review June 21, 2026 00:22

Dismissing prior approval to re-evaluate 6604762

@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Jun 21, 2026
@juliusmarminge juliusmarminge force-pushed the codex/web-preview-error-context branch from 6604762 to 83d49a1 Compare June 21, 2026 00:25
@juliusmarminge juliusmarminge force-pushed the codex/web-preview-error-context branch from 83d49a1 to 5dc67af Compare June 21, 2026 00:26
@juliusmarminge juliusmarminge force-pushed the codex/web-preview-error-context branch from 5dc67af to b6ec6cf Compare June 21, 2026 00:30
@juliusmarminge juliusmarminge force-pushed the codex/web-preview-error-context branch from b6ec6cf to 9952de4 Compare June 21, 2026 00:32
@juliusmarminge juliusmarminge force-pushed the codex/web-preview-error-context branch 2 times, most recently from 6c4608c to f1b1d68 Compare June 21, 2026 00:45
@juliusmarminge juliusmarminge force-pushed the codex/web-preview-error-context branch from f1b1d68 to 6e21cc7 Compare June 21, 2026 01:11
@juliusmarminge juliusmarminge force-pushed the codex/web-preview-error-context branch from 6e21cc7 to 2d0461b Compare June 21, 2026 01:22
Co-authored-by: codex <codex@users.noreply.github.com>
@juliusmarminge juliusmarminge force-pushed the codex/web-preview-error-context branch from 2d0461b to 56e0750 Compare June 21, 2026 01:39
@juliusmarminge juliusmarminge merged commit 27ac96a into codex/stack-pr-3259 Jun 21, 2026
16 checks passed
@juliusmarminge juliusmarminge deleted the codex/web-preview-error-context branch June 21, 2026 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant